﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.AI;

/// <summary>
/// IRenderEngine----->IShape
/// </summary>
public class DM02Bridge : MonoBehaviour
{
    /*private Sphere m_spere = new Sphere();
    private Cube m_cube = new Cube();
    private void Start()
    {
        m_cube.Draw();
        m_spere.Draw();
    }*/
    private IRenderEngine m_render = new OpenGL();
    private void Start()
    {
        Sphere myS = new Sphere(m_render);
        myS.Draw();
        Cube myC = new Cube(m_render);
        myC.Draw();
    }



}
public abstract class IShape
{
    protected string m_name;
    protected IRenderEngine m_renderEngine;
    public IShape(string name,IRenderEngine renderengine)
    {
        m_name = name;
        m_renderEngine = renderengine;

    }
  
    //public IRenderEngine RenderEngine { set { m_renderEngine = value; } }
    public virtual void Draw()
    {
        m_renderEngine.Renderer(m_name);
    }
}
public abstract class IRenderEngine
{
    public abstract void Renderer(string name);
}
public class Sphere:IShape
{
    public Sphere(IRenderEngine renderEngine) : base("sphere",renderEngine) { }
    
    
}
public class Cube:IShape
{
    public Cube(IRenderEngine renderEngine) : base("cube",renderEngine) { }
   
}
public class OpenGL:IRenderEngine
{
    public override void Renderer(string name)
    {
        Debug.Log("OPENGL IS RENDERERING:" +name);
    }
}

